<html lang='en' xml:lang='en' xmlns="http://www.w3.org/1999/xhtml">
<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Vuong Tuan-Dictionary</title>
</head>
<body>
<?php 
	$dict = isset($_POST['dict'])? $_POST['dict'] : 1;
	$word = isset($_POST['word']) ? $_POST['word'] : '';
?>
<!-- FORM -->
<div>
<form action="dictionary.php" method="post">
  <input type="hidden" name="co" id="co" value="" />
  <div style="float: left; padding: 5px; text-align:left" align="left">
	  	  <div width="205" align="left">
			  <select name="dict" id="gdict" class="ginputform" onchange="changeDictionary(this.value);" style="width:210px; font-weight:normal; font-size:10px; color:#666666">
				<option value="1" <?php if ($dict == 1 ) { echo 'selected="selected"';}?> > English - Vietnamese dictionary</option>
				<option value="2" <?php if ($dict == 2 ) { echo 'selected="selected"';}?>> Vietnamese - English dictionary</option>
			  </select><br />

			  <input type="text" name="word" value="<?php echo $word; ?>" style="width:210px;"/>
		  </div>
		  <div width="205" align="right">
          <input type="submit" name="searchaction" value="Tìm" class="ginputform" /> 
		  </div>
		  </div>
</form>	
</div>
<!-- FORM -->
<br/><br/><br/><br/>

<!-- RESULT CONTENT -->
<div>
<?php
error_reporting(E_ALL);
ini_set('display_errors', '0');

if ($word) {
	$homepage = file_get_contents("http://vdict.com/gateway.php?co=&dict=$dict&word=$word");
	
	preg_match_all("/<table[^>]*>(.+?)<\/table>/is", $homepage, $matches);
 	
	$pronun = isset($matches[1][3]) ? $matches[1][3] : '';
	$content = isset($matches[1][4]) ? $matches[1][4] : 'Không tìm thấy từ ' . $word;
	
	echo '<p style="font-size: 22px; color: #0066CC;">' . $word . '</p>';
	echo $pronun;
	echo '<br/>';
	echo $content;
}
?>
</div>
<!-- RESULT CONTENT -->
</body>
</html>
